package extensions
{
	public class XMLHelper
	{
		public static function previousSibling( theNode:XML):XML
		{
			if(theNode.parent() != null && theNode.childIndex() > 0)
			{
				return theNode.parent().*[theNode.childIndex()-1];
			}
			else
			{
				return null;
			}
		}
		
		public static function nextSibling( theNode:XML):XML
		{
			if(theNode.parent() != null && theNode.childIndex() > 0)
			{
				return theNode.parent().*[theNode.childIndex()+1];
			}
			else
			{
				return null;
			}
		}
		
		public static function getRoot(childNode:XML):XML
		{
			var parentNode:XML = childNode.parent();
			return (parentNode != null) ? getRoot(parentNode) : childNode;
		}
	}
}